<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>SYS_FS_Mount Function</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="generator" content="Doc-O-Matic" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <link rel="STYLESHEET" href="default.css" type="text/css" />

<script type="text/javascript" src="scripts.js"></script>
</head>
<body class="Element700" onload="onBodyLoadEx('frames.html', 'topic', '01117.html');" onmousedown="onBodyMouseDown();">

<!-- Begin Popups -->

<!-- End Popups -->

<!-- Begin Page Header -->
<div class="Element710" id="areafixed">
<div class="Element94">
<a href="01259.html" target="topic">System Service Libraries Help</a> &gt; <a href="00735.html" target="topic">File System Service Library Help</a> &gt; <a href="00736.html" target="topic">Library Interface</a> &gt; b) General Operation Functions &gt; <a href="01117.html" target="topic">SYS_FS_Mount Function</a></div>
<div class="Element92">
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td width="25%">
<div class="Element1">
MPLAB Harmony Core Help</div>
</td><td width="25%">
<div class="Element2">
<a href="contents.html" target="tocidx">Contents</a> | <a href="00007.html" target="topic">Home</a></div>
</td><td width="25%">
<div class="Element90">
<a href="01124.html" target="topic">Previous</a> | <a href="00736.html" target="topic">Up</a> | <a href="01137.html" target="topic">Next</a></div>
</td><td width="25%">
<div class="Element96">
<a href="mailto:docerrors@microchip.com&subject=MPLAB Harmony Documentation Feedback (Topic ID: SYS_FS_Mount@char *@char *@SYS_FS_FILE_SYSTEM_TYPE@unsigned long@void * Topic Title: SYS_FS_Mount Function)&body=Thank you for your feedback! Please include a description of your feedback, and indicate whether you are reporting an an error in the documentation or an enhancement.">Documentation Feedback</a><br> <a href="http://support.microchip.com" target="_blank">Microchip Support</a></div>
</td></tr></table><div class="Element5">
SYS_FS_Mount Function</div>
</div>
</div>

<!-- End Page Header -->

<!-- Begin Client Area -->
<div class="Element720" id="areascroll">
<div class="Element721">

<!-- Begin Page Content -->
<a name="PageContent"></a><div class="Element58">
<a name="4465736372697074696F6E"></a><div class="Element11">
<div class="Element10">
<p class="Element10">
The mount command attaches the file system specified to a volume. The call to the mount should be non blocking in nature. The application code has to allow the <a href="01124.html" target="topic">SYS_FS_Tasks</a> to run periodically while calling the SYS_FS_Mount function. If the SYS_FS_Mount is called in a blocking mode, then the SYS_Tasks() never gets a chance to run and therefore, the media will not be analyzed and finally, the SYS_FS_Mount will never succeed. This will result in a deadlock.&nbsp;</p>
<p class="Element10">
There is no mechanism available for the application to know if the specified volume (devName) is really attached or not. The only available possibility is to keep trying to mount the volume (with the devname), until success is achieved or use the Automount feature.&nbsp;</p>
<p class="Element10">
It is prudent that the application code implements a time-out mechanism while trying to mount a volume (by calling SYS_FS_Mount). The trial for mount should continue at least 10 times before before assuming that the mount will never succeed. This has to be done for every new volume to be mounted.&nbsp;</p>
<p class="Element10">
Once the mount is successful the application needs to use <a href="00911.html" target="topic">SYS_FS_Error</a>() API to know if the mount was successful with valid filesystem on media or not. If SYS_FS_ERROR_NO_FILESYSTEM is returned application needs to Format the media using the <a href="00906.html" target="topic">SYS_FS_DriveFormat</a>() API before performing any operations.&nbsp;</p>
<p class="Element10">
The standard names for volumes (devName) used in the MPLAB Harmony file system is as follows: NVM - &quot;nvm&quot; &quot;media number&quot; &quot;volume number&quot; SD card - &quot;mmcblk&quot; &quot;media number&quot; &quot;volume number&quot; MSD - &quot;sd&quot; &quot;media number&quot; &quot;volume number&quot;&nbsp;</p>
<p class="Element10">
Where, &quot;media number&quot; a, b, c... depends on the number of the type of connected media, and where, &quot;volume number&quot; 1, 2, 3... depends on the number of partitions in that media.&nbsp;</p>
<p class="Element10">
The convention for assigning names to volumes is further described below with examples:&nbsp;</p>
<p class="Element10">
If a SD card (with four partitions) is attached to the system, and assuming all four partitions are recognized, there will be four devNames:</p>
<ol class="Element630">
<li value="1" class="Element600">mmcblka1</li>
<li value="2" class="Element600">mmcblka2</li>
<li value="3" class="Element600">mmcblka3 and </li>
<li value="4" class="Element600">mmcblka4</li>
</ol><p class="Element10">
&nbsp;</p>
<p class="Element10">
Subsequently, if NVM media is attached that has only one partition, the devname will be: nvma1.&nbsp;</p>
<p class="Element10">
Later, if another SD card is attached to the system that has one partition, the devname will be mmcblkb1.&nbsp;</p>
<p class="Element10">
Finally, there will be six volume names (or devNames), which are available for the application to be mounted and used for the file system.</p></div>
</div>
<a name="43"></a><div class="Element99">
C</div>
<div class="Element101"><div class="Element100"><pre class="Element100"><a href="01121.html" target="topic">SYS_FS_RESULT</a> <strong><span style="color: #000000">SYS_FS_Mount</span></strong>(
    <strong><span style="color: #000080">const</span></strong> <strong><span style="color: #000080">char</span></strong> * <strong><span style="color: #000000">devName</span></strong>, 
    <strong><span style="color: #000080">const</span></strong> <strong><span style="color: #000080">char</span></strong> * <strong><span style="color: #000000">mountName</span></strong>, 
    <a href="00965.html" target="topic">SYS_FS_FILE_SYSTEM_TYPE</a> <strong><span style="color: #000000">filesystemtype</span></strong>, 
    <strong><span style="color: #000080">unsigned</span></strong> <strong><span style="color: #000080">long</span></strong> <strong><span style="color: #000000">mountflags</span></strong>, 
    <strong><span style="color: #000080">const</span></strong> <strong><span style="color: #000080">void</span></strong> * <strong><span style="color: #000000">data</span></strong>
);</pre></div></div>
<a name="507265636F6E646974696F6E73"></a><div class="Element14">
Preconditions</div>
<div class="Element11">
<div class="Element10">
<p class="Element10">
The &quot;devName&quot; name for the volume has to be known. The file system type with which each of the volumes are formatted has to be known. Trying to mount a volume with a file system which is different from what the volume is actually formatted, will cause mount failure.</p></div>
</div>
<a name="506172616D6574657273"></a><div class="Element14">
Parameters</div>
<div class="Element11">
<div class="Element10">
<div class="Element312">
<div class="TableDiv">
<table cellspacing="0" class="Table3">
<tr>
<td class="Element300" valign="top" width="35%">
<div class="Element301">
Parameters&nbsp;</div></td><td class="Element304" valign="top" width="65%">
<div class="Element305">
Description&nbsp;</div></td></tr><tr>
<td class="Element302" valign="top" width="35%">
<div class="Element303">
devName&nbsp;</div></td><td class="Element306" valign="top" width="65%">
<div class="Element307">
The device name (name of volume) which needs to be mounted. The devName has to be preceded by the string &quot;/dev/&quot;.&nbsp;</div></td></tr><tr>
<td class="Element302" valign="top" width="35%">
<div class="Element303">
mountName&nbsp;</div></td><td class="Element306" valign="top" width="65%">
<div class="Element307">
Mount name for the device to be mounted. This is a name provided by the user. In future, while accessing the mounted volume (say, during <a href="00978.html" target="topic">SYS_FS_FileOpen</a> operation), the mountName is used to refer the path for file. The mount name has to be preceded by the string &quot;/mnt/&quot;&nbsp;</div></td></tr><tr>
<td class="Element302" valign="top" width="35%">
<div class="Element303">
filesystemtype&nbsp;</div></td><td class="Element306" valign="top" width="65%">
<div class="Element307">
Native file system of <a href="00965.html" target="topic">SYS_FS_FILE_SYSTEM_TYPE</a> type.&nbsp;</div></td></tr><tr>
<td class="Element302" valign="top" width="35%">
<div class="Element303">
mountflags&nbsp;</div></td><td class="Element306" valign="top" width="65%">
<div class="Element307">
Mounting control flags. This parameter is reserved for future enhancements. Therefore, always pass zero.&nbsp;</div></td></tr><tr>
<td class="Element302" valign="top" width="35%">
<div class="Element303">
data&nbsp;</div></td><td class="Element306" valign="top" width="65%">
<div class="Element307">
The data argument is interpreted by the different file systems. This parameter is reserved for future enhancements. Therefore, always pass NULL.&nbsp;</div></td></tr></table></div></div>
</div>
</div>
<a name="52657475726E73"></a><div class="Element14">
Returns</div>
<div class="Element11">
<div class="Element10">
<p class="Element10">
SYS_FS_RES_SUCCESS - Mount was successful. SYS_FS_RES_FAILURE - Mount was unsuccessful. The reason for the failure can be retrieved with <a href="00911.html" target="topic">SYS_FS_Error</a>.</p></div>
</div>
<a name="52656D61726B73"></a><div class="Element14">
Remarks</div>
<div class="Element11">
<div class="Element10">
<p class="Element10">
None</p></div>
</div>
<a name="4578616D706C65"></a><div class="Element14">
Example</div>
<div class="Element11">
<div class="Element10">
<div class="Element13"><div class="Element12"><pre class="Element12">  <strong><span style="color: #000080">switch</span></strong>(appState)
  {
      <strong><span style="color: #000080">case</span></strong> TRY_MOUNT:
          <strong><span style="color: #000080">if</span></strong>(SYS_FS_Mount(&quot;/dev/mmcblka1&quot;, &quot;/mnt/myDrive&quot;, FAT, 0, NULL) != SYS_FS_RES_SUCCESS)
          {
              <i><span style="color: #008000">// Failure, try mounting again</span></i>
          }
          <strong><span style="color: #000080">else</span></strong>
          {
              <i><span style="color: #008000">// Mount was successful. Check for File System</span></i>

              <strong><span style="color: #000080">if</span></strong> (<a href="00911.html" target="topic">SYS_FS_Error</a>() == SYS_FS_ERROR_NO_FILESYSTEM)
              {
                  <i><span style="color: #008000">//Perform Driver Format operation as there is no filesystem on media</span></i>
                  <a href="00906.html" target="topic">SYS_FS_DriveFormat</a>(...);
              }

              appState = DO_FURTHER_STUFFS;
          }
      <strong><span style="color: #000080">break</span></strong>;
  }</pre></div></div>
</div>
</div>
</div>
<!-- End Page Content -->

<!-- Begin Page Footer -->
<div class="Element95">
<a href="01259.html" target="topic">System Service Libraries Help</a> &gt; <a href="00735.html" target="topic">File System Service Library Help</a> &gt; <a href="00736.html" target="topic">Library Interface</a> &gt; b) General Operation Functions &gt; <a href="01117.html" target="topic">SYS_FS_Mount Function</a></div>
<div class="Element93">
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td width="25%">
<div class="Element3">
MPLAB Harmony Core Help</div>
</td><td width="25%">
<div class="Element4">
<a href="contents.html" target="tocidx">Contents</a> | <a href="00007.html" target="topic">Home</a></div>
</td><td width="25%">
<div class="Element91">
<a href="01124.html" target="topic">Previous</a> | <a href="00736.html" target="topic">Up</a> | <a href="01137.html" target="topic">Next</a></div>
</td><td width="25%">
<div class="Element97">
<a href="mailto:docerrors@microchip.com&subject=MPLAB Harmony Documentation Feedback (Topic ID: SYS_FS_Mount@char *@char *@SYS_FS_FILE_SYSTEM_TYPE@unsigned long@void * Topic Title: SYS_FS_Mount Function)&body=Thank you for your feedback! Please include a description of your feedback, and indicate whether you are reporting an an error in the documentation or an enhancement.">Documentation Feedback</a><br> <a href="http://support.microchip.com" target="_blank">Microchip Support</a></div>
</td></tr></table></div>

<!-- End Page Footer -->
</div>
</div>

<!-- End Client Area -->
</body></html>